import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { HeroService } from './hero.service';
import { GetHeroListDto } from './dto/get-hero-list.dto';
import { CreateHeroDto, DeleteHeroDto, UpdateHeroDto } from './dto/hero.dto';

@Controller('hero')
export class HeroController {
  constructor(private heroService: HeroService) {}

  @Post('/getHeroList')
  async getHeroList(@Body() dto: GetHeroListDto) {
    return this.heroService.find(dto);
  }

  @Post('/create')
  async create(@Body() dto: CreateHeroDto) {
    return this.heroService.create(dto);
  }

  @Post('/update')
  async update(@Body() dto: UpdateHeroDto) {
    return this.heroService.update(dto);
  }

  @Post('/delete')
  async delete(@Body() dto: DeleteHeroDto) {
    return this.heroService.delete(dto);
  }

  @Get('/getHero/:id')
  async getHeroDetail(@Param('id') id: number) {
    return this.heroService.findOne(id);
  }
}
